package com.llxwz.config.mq;

import com.llxwz.util.CommunityConstant;
import com.llxwz.util.CommunityUtil;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ProduceRabbitConfig implements CommunityConstant {

    @Bean
    public Queue commentQueue() {
        return new Queue(QUEUE_COMMENT, true);
    }
    @Bean
    public Queue likeQueue() {
        return new Queue(QUEUE_LIKE, true);
    }
    @Bean
    public Queue followQueue() {
        return new Queue(QUEUE_FOLLOW, true);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(EXCHANGE_NAME, true, false);
    }

    @Bean
    public Binding bindingDirect1() {
        return BindingBuilder.bind(commentQueue()).to(directExchange()).with(ROUTE_COMMENT);
    }
    @Bean
    public Binding bindingDirect2() {
        return BindingBuilder.bind(likeQueue()).to(directExchange()).with(ROUTE_LIKE);
    }
    @Bean
    public Binding bindingDirect3() {
        return BindingBuilder.bind(followQueue()).to(directExchange()).with(ROUTE_FOLLOW);
    }
}
